<script setup lang="ts">
import {ref} from "vue";

const toy = ref('奥特曼')
const book = ref(3)

//把数据交给外部，可以向子组件，也可以向父组件
defineExpose({toy, book})

function minusHouse(parent) {
  console.log('parent', parent)
  parent.house -= 1
}
</script>

<template>
<h3>子组件1</h3>
  <h4>玩具：{{toy}}</h4>
  <h4>书籍：{{book}}本</h4>
  <button @click="minusHouse($parent)">干掉父亲一套房产</button>
  <hr>
</template>

<style scoped>

</style>